home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / faccess.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-25  |  1.0 KB  |  45 lines

  1. /*
  2.  *
  3.  * faccess.c
  4.  * Version 0.00.03
  5.  * June 16, 1995
  6.  * Copyright (C) 1995 Alexander O. Yuriev, CIS Laboratories, TEMPLE UNIVERSITY
  7.  * GNU General Public License terms apply.
  8.  * 
  9.  * Modified by Olaf Kirch.
  10.  */
  11.  
  12. #include <sys/stat.h>
  13. #include <unistd.h>
  14. #include <errno.h>
  15.  
  16. #include "faccess.h"
  17.  
  18. int
  19. iCheckAccess(pchFilename, uidOwner, gidOwner)
  20.     char *pchFilename;
  21.     uid_t uidOwner;
  22.     gid_t gidOwner;
  23. {
  24.   struct stat statData;
  25.   int status = FACCESSOK;
  26.   
  27.   if (stat(pchFilename,&statData) == -1) {
  28.       if (errno == ENOENT)
  29.         status = FACCESSNOTFOUND;
  30.       else status = FACCESSIOERR;
  31.   } else {
  32.        if ((statData.st_mode & S_IWOTH) ||
  33.          (statData.st_mode & S_IWGRP) ||
  34.          ((statData.st_uid != uidOwner) && (statData.st_mode & S_IWUSR))) {
  35.            status = FACCESSWRITABLE;
  36.        } else if ((statData.st_uid != uidOwner) ||
  37.                (statData.st_gid != gidOwner)) {
  38.                 status = FACCESSBADOWNER;
  39.        } else if ((statData.st_mode & S_IROTH)) {
  40.          status = FACCESSWARN;
  41.        }
  42.   }
  43.   return status;
  44. }
  45.